#include "mainwindow.h"
#include "ui/common/splashscreen.h"
#include <QApplication>
#include <QDebug>
#include <QProcessEnvironment>

int main(int argc, char *argv[])
{
    // 设置环境变量以消除警告
    qputenv("XDG_RUNTIME_DIR", "/tmp/runtime-root");
    qputenv("QT_LOGGING_RULES", "qt.qpa.input=false");
    
    QApplication app(argc, argv);
    app.setApplicationName("IMX6ULL Desktop App");
    app.setApplicationVersion("1.0.0");
    app.setOrganizationName("IMX6ULL");
    qDebug() << "启动 IMX6ULL 桌面应用...";
    qDebug() << "Qt版本:" << qVersion();
    
    MainWindow *mainWindow = new MainWindow();
    
    SplashScreen *splash = new SplashScreen();
    
    // 当启动画面完成时，显示主窗口并销毁启动画面
    QObject::connect(splash, &SplashScreen::splashFinished, [splash, mainWindow]() {
        qDebug() << "启动画面完成，显示主窗口";
        mainWindow->show();
        splash->close();
        splash->deleteLater();
    });
    
    // 显示启动画面
    splash->show();
    
    return app.exec();
}

